package cn.com.nes.site.controller.logs;


import cn.com.nes.common.web.CommonResult;
import cn.com.nes.mybatis.agent.logs.entity.ImportLogDetails;
import cn.com.nes.mybatis.agent.logs.entity.ImportLogs;
import cn.com.nes.site.controller.logs.vo.EndCustomerSaleImportDetailLogPageVO;
import cn.com.nes.site.controller.logs.vo.EndCustomerSaleImportMainLogPageVO;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.service.logs.ImportLogDetailsService;
import cn.com.nes.site.service.logs.ImportLogsService;
import cn.com.nes.site.service.logs.bo.ImportDetailLogPageBO;
import cn.com.nes.site.service.logs.bo.ImportMainLogPageBO;
import cn.com.nes.site.service.logs.dto.ImportDetailLogDTO;
import cn.com.nes.site.service.logs.dto.ImportMainLogDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = {"销售管理-销售"})
@RestController
@RequestMapping("/v2/logs")
public class ImportLogsConteroller {

    @Resource
    private ImportLogDetailsService importLogDetailsService;

    @Resource
    private ImportLogsService importLogsService;

    @RequestMapping(value = "queryLogsData", method = RequestMethod.POST)
    public PageData queryLogsData(@RequestBody ImportLogs importLogs) {
        return importLogsService.queryLogsData(importLogs);
    }

    @RequestMapping(value = "queryCustomerInfoData", method = RequestMethod.POST)
    public PageData queryCustomerInfoData(@RequestBody ImportLogDetails importLogDetails) throws Exception {
        return importLogDetailsService.queryCustomerInfoData(importLogDetails);
    }

    @ApiOperation("终端客户销售导入主日志分页查询")
    @RequestMapping(value = "/endCustomerSaleImportMainLogPage", method = RequestMethod.GET)
    public CommonResult<ImportMainLogDTO> endCustomerSaleImportMainLogPage(
            @Validated EndCustomerSaleImportMainLogPageVO vo) throws Exception {
        ImportMainLogPageBO importMainLogPageBO = vo.convertToBo(ImportMainLogPageBO.class);
        importMainLogPageBO.setImportBusinessType("01");
        importMainLogPageBO.setBid(vo.getOpportunityUuid());
        return CommonResult.page(importLogsService.importMainLogPage(importMainLogPageBO));
    }

    @ApiOperation("终端客户销售导入明细日志分页查询")
    @RequestMapping(value = "/endCustomerSaleImportDetaiLogPage", method = RequestMethod.GET)
    public CommonResult<ImportDetailLogDTO> endCustomerSaleImportDetaiLogPage(
            @Validated EndCustomerSaleImportDetailLogPageVO vo) throws Exception {
        return CommonResult.page(importLogDetailsService.importDetaiLogPage(vo.convertToBo(ImportDetailLogPageBO.class)));
    }


}
